//
//  HZJRetweetedCell.swift
//  WeiBo
//
//  Created by 陈贵 on 15/9/15.
//  Copyright © 2015年 hzj. All rights reserved.
//

import UIKit

class HZJRetweetedCell: HZJCell {
    
    //此方法可不用super
    override var statusesViewModel:StatusesViewModel? {
        didSet{
            retweetedLable.text = statusesViewModel?.retweetedText
        }
    }
    
    
    
    override func setUI() {
        super.setUI()
        contentView.insertSubview(retweetedBth, belowSubview: pictureView)
        contentView.insertSubview(retweetedLable, aboveSubview: retweetedBth)
        
        //转发微博的总框体
        retweetedBth.translatesAutoresizingMaskIntoConstraints = false
        addConstraint( NSLayoutConstraint(item: retweetedBth, attribute: NSLayoutAttribute.Top, relatedBy: NSLayoutRelation.Equal, toItem: textView, attribute: NSLayoutAttribute.Bottom, multiplier: 1, constant: HZJPICTUREMARGIN))
        addConstraint( NSLayoutConstraint(item: retweetedBth, attribute: NSLayoutAttribute.Left, relatedBy: NSLayoutRelation.Equal, toItem: self, attribute: NSLayoutAttribute.Left, multiplier: 1, constant: 0))
        addConstraint( NSLayoutConstraint(item: retweetedBth, attribute: NSLayoutAttribute.Right, relatedBy: NSLayoutRelation.Equal, toItem: self, attribute: NSLayoutAttribute.Right, multiplier: 1, constant: 0))
        addConstraint( NSLayoutConstraint(item: retweetedBth, attribute: NSLayoutAttribute.Bottom, relatedBy: NSLayoutRelation.Equal, toItem: bottomView, attribute: NSLayoutAttribute.Top, multiplier: 1, constant: 0))
        
        //转发的文字
        retweetedLable.translatesAutoresizingMaskIntoConstraints = false
        addConstraint( NSLayoutConstraint(item: retweetedLable , attribute: NSLayoutAttribute.Top, relatedBy: NSLayoutRelation.Equal, toItem: retweetedBth, attribute: NSLayoutAttribute.Top, multiplier: 1, constant: HZJPICTUREMARGIN))
        addConstraint( NSLayoutConstraint(item: retweetedLable , attribute: NSLayoutAttribute.Left, relatedBy: NSLayoutRelation.Equal, toItem: retweetedBth, attribute: NSLayoutAttribute.Left, multiplier: 1, constant: HZJPICTUREMARGIN))

        //图片
        pictureView.translatesAutoresizingMaskIntoConstraints = false
        addConstraint(NSLayoutConstraint(item: pictureView, attribute: NSLayoutAttribute.Top, relatedBy: NSLayoutRelation.Equal, toItem: retweetedLable, attribute: NSLayoutAttribute.Bottom, multiplier: 1, constant: 0))
        pictureTop = constraints.last
        
        addConstraint(NSLayoutConstraint(item: pictureView, attribute: NSLayoutAttribute.Left, relatedBy: NSLayoutRelation.Equal, toItem: retweetedLable, attribute: NSLayoutAttribute.Left, multiplier: 1, constant: 0))
        addConstraint(NSLayoutConstraint(item: pictureView, attribute: NSLayoutAttribute.Width, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1, constant: 2 * HZJPICTURESIZE))
        PictureWidth = constraints.last
        
        addConstraint(NSLayoutConstraint(item: pictureView, attribute: NSLayoutAttribute.Height, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1, constant: HZJPICTURESIZE))
        PictureHeight = constraints.last

        
        
        
    }
    
    
/// 懒加载
    ///整体按钮
    private lazy var retweetedBth:UIButton = {
        let bth = UIButton()
        bth.backgroundColor = UIColor(white: 0.9, alpha: 1)
        return bth
    }()
/// 转发文字
    private lazy var retweetedLable:UILabel = UILabel(title: "请问而发生的企鹅我人品全省理科；放假啊；是父亲陪；安家费", color: UIColor.brownColor(), fontSize: 14,layoutWidth:UIScreen.mainScreen().bounds.width - 2 * HZJMargin)
    
    

}
